package cool.webstudy.admin.controller.team;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import cool.webstudy.admin.model.dto.team.CreateTeamDTO;
import cool.webstudy.admin.model.dto.team.PaginationQueryTeamInfoListDTO;
import cool.webstudy.admin.model.dto.team.UpdateTeamDTO;
import cool.webstudy.admin.model.vo.team.PaginationQueryTeamInfoListVO;
import cool.webstudy.admin.model.vo.team.QueryTeamDetailInfoVO;
import cool.webstudy.admin.model.vo.team.QueryTeamRoughInfoVO;
import cool.webstudy.admin.service.TeamService;
import cool.webstudy.admin.utils.aspect.request.RequestParameterCheck;
import cool.webstudy.admin.utils.common.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Tag(name = "队伍管理")
@RestController
@RequestMapping("/team")
@RequestParameterCheck
public class TeamController {
    @Autowired TeamService teamService;


    @GetMapping("/query/detail-info")
    @Operation(summary = "获取队伍详细信息接口")
    public Result queryDetailInfo(@RequestParam String unCode) {
        QueryTeamDetailInfoVO vo = teamService.queryTeamDetailInfo(unCode);

        return Result.success(vo);
    }

    @PostMapping("/create")
    @Operation(summary = "创建队伍接口")
    public Result create(@RequestBody CreateTeamDTO dto){
        teamService.createTeam(dto);
        return Result.success();
    }


    @PostMapping("/update")
    @Operation(summary = "更新队伍接口")
    public Result update(@RequestBody UpdateTeamDTO dto){
        teamService.updateTeam(dto);
        return Result.success();
    }

    @PostMapping("/batch/delete")
    @Operation(summary = "批量删除队伍接口")
    public Result batchDelete(@RequestBody List<String> unCodeList) {
        teamService.batchDeleteTeam(unCodeList);
        return Result.success();
    }


    @PostMapping("/page-query/list")
    @Operation(summary = "分页获取队伍信息列表接口")
    public Result<Page<PaginationQueryTeamInfoListVO>> paginationQueryTeamInfoList(@RequestBody PaginationQueryTeamInfoListDTO dto) {
    Page<PaginationQueryTeamInfoListVO> vo = teamService.paginationQueryTeamInfoList(dto);
    return Result.success(vo);
    }
    @GetMapping("/query/rough-info/list")
    @Operation(summary = "获取队伍基本信息列表接口")
    public Result<List<QueryTeamRoughInfoVO>> queryTeamRoughInfoList() {
        List<QueryTeamRoughInfoVO> vo = teamService.queryTeamRoughInfoList();
        return Result.success(vo);
    }
}
